from universal.common_header import *

def setAct(self,picture,NoEdit=False):#为你的编辑框设置小图标按钮
    imgspathLineEdit = QLineEdit()
    if NoEdit:
        imgspathLineEdit.setReadOnly(True)
    actLine = QAction(imgspathLineEdit)
    actLine.setIcon(QIcon(picture))
    imgspathLineEdit.addAction(actLine, QLineEdit.TrailingPosition)
    return imgspathLineEdit,actLine

def Button(name,function=None):
    Button = QPushButton(name)
    Button.setStyleSheet('''QPushButton{background:rgb(0,125,0);
            border-radius:5px;}QPushButton:hover{background:blue;}''')
    if function:
        Button.clicked.connect(function)
    return Button

def ButtonColor(button,news1):
    button.setText(news1)
    button.setStyleSheet('''QPushButton{background:rgb(0,125,0);border-radius:5px;}QPushButton:hover{background:blue;}''')

def ButtonColor_stop(button,news1):
    button.setText(news1)
    button.setStyleSheet('''QPushButton{background:rgb(255,0,0);
           border-radius:5px;}QPushButton:hover{background:blue;}''')

def ADD_DOCK_lEFT(dock, widget_):
    widget = QDockWidget()
    widget.setMaximumWidth(1000)
    widget.setTitleBarWidget(QWidget())
    widget.setWidget(widget_)
    dock(Qt.LeftDockWidgetArea, widget)
    return widget